import { http } from '@/utils/http/axios';

export interface BasicPageParams {
  pageNumber: number;
  pageSize: number;
  total: number;
}
//#region  增删改查
//获取分页数据
export function getPageList(params) {
  return http.request({
    url: '/System/SysUser/GetPageList',
    method: 'get',
    params
  });
}

/**
 * 新增
 * @returns 
 */
export function add(data: object) {
  return http.request({
    url: '/System/SysUser/Add',
    method: 'POST',
    data
  });
}


/**
 * 修改
 * @returns 
 */
export function update(data: object) {
  return http.request({
    url: '/System/SysUser/Update',
    method: 'POST',
    data
  });
}

/**
 * 修改启用状态
 * @returns 
 */
export function updateEnabled(data: object) {
  return http.request({
    url: '/System/SysUser/UpdateEnabled',
    method: 'POST',
    data
  });
}

/**
 * 重置密码
 * @returns 
 */
export function resetPassword(data: object) {
  return http.request({
    url: '/System/SysUser/ResetPassword',
    method: 'POST',
    data
  });
}
/**
 * 删除
 * @returns 
 */
export function deleteById(id: string) {
  return http.request({
    url: `/System/SysUser/Delete?id=${id}`,
    method: 'POST',
  });
}
//#endregion

/**
 * @description: 获取用户信息
 */
export function getUserInfo() {
  return http.request({
    url: '/System/SysUser/GetUserInfo',
    method: 'get',
  });
}

/**
 * @description: 用户登录
 */
export function login(params) {
  return http.request(
    {
      url: '/System/SysUser/Login',
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

/**
 * 刷新token
 * @param params 
 * @returns 
 */
export function refreshToken(params) {
  return http.request(
    {
      url: '/System/SysUser/RefreshToken',
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

/**
 * @description: 用户修改密码
 */
export function changePassword(params, uid) {
  return http.request(
    {
      url: `/user/u${uid}/changepw`,
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

/**
 * @description: 用户登出
 */
export function logout(params) {
  return http.request({
    url: '/login/logout',
    method: 'POST',
    params,
  });
}
